var login = {
    /*登录区域*/
    selector: '.login',
    /*登录地址*/
    url: base + '/auth.do',
    /*验证码地址*/
    captchaUrl: base + '/captcha.do',
    /*登录成功的回调函数*/
    successCallback: function (data) {
        alert('登录成功');
    },
    /*登录失败的回调函数*/
    failureCallbackL: function (data) {
        alert(msg[data.code]);
    }
};
/*提交登录*/
login.submit = function () {
    if (!checkForm($(login.selector).find('input[name]'))) {
        return;
    }
    var data = LC.serializeArray($(login.selector).find('input[name]'));
    data.push({name: 'act', value: 'in'});
    $.ajax({
        url: login.url,
        dataType: "JSON",
        cache: false,
        data: data,
        success: function (rs) {
            if (rs.code == code.SUCCESS) {
                login.successCallback(rs);
            } else {
                if (rs.code == 2)
                    login.fleshCaptcha();
                login.failureCallbackL(rs);
            }
        }
    });
}
/**
 * 重置登录信息
 * */
login.reset = function () {
    $(login.selector)[0].reset();
    login.fleshCaptcha();
    $(login.selector).find('input[name=userName]').focus();
}
/**
 * 刷新验证码
 */
login.fleshCaptcha = function () {
    $('#captchaimg').attr('src', login.captchaUrl + '?_=' + Math.random());
    $('#captcha').val('');
    $('#captcha').focus();
}